package com.ashen.study.controller;


import com.ashen.study.entity.UserInfo;
import com.ashen.study.model.request.UserRequest;
import com.ashen.study.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author huangxiaolin
 * @version 1.0.0
 * @ClassName UserInfoController.java
 * @Description
 * @createTime 2019年05月06日 15:36:00
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户管理测试版")
public class UserInfoController {

    @Resource
    private UserInfoService userInfoService;


    @GetMapping("/userInfo")
    @ApiOperation("获取用户信息")
    private List<UserInfo> getUserInfoList() {
        return userInfoService.getUserInfo();
    }


    @PostMapping("/insert")
    @ApiOperation("新增用户信息")
    private boolean insert(@RequestBody UserRequest request) {
        UserRequest userRequest = UserRequest.addOf(request);
        return userInfoService.insert(userRequest);
    }

    @PostMapping("/update")
    @ApiOperation("更新用户信息")
    private boolean update(@RequestBody UserRequest request) {
        UserRequest userRequest = UserRequest.updateOf(request);
        return userInfoService.update(userRequest);
    }


    @GetMapping("/delete")
    @ApiOperation("删除用户信息")
    private boolean delete(Integer id) {
        return userInfoService.delete(id);
    }

}
